StupidBeauty
Read times:400Posted at:Fri Jun 8 17:08:04 2012
- no title specified

转载:Bash Shell中命令行选项/参数处理

参数的个数为$#,所有参数组成的字符串为$*。

http://www.cnblogs.com/FrankTan/archive/2010/03/01/1634516.html

亮点:

手工处理方式


在手工处理方式中,首先要知道几个变量,还是以上面的命令行为例:

* $0 : ./test.sh,即命令本身,相当于C/C++中的argv[0]
* $1 : -f,第一个参数.
* $2 : config.conf
* $3, $4 ... :类推。
* $# 参数的个数,不包括命令本身,上例中$#为4.
* $@ :参数本身的列表,也不包括命令本身,如上例为 -f config.conf -v --prefix=/home
* $* :和$@相同,但"$*" 和 "$@"(加引号)并不同,"$*"将所有的参数解释成一个字符串,而"$@"是一个参数数组。如下例所示:

Your opinions
Your name:Email:Website url:Opinion content:
- no title specified

HxLauncher: Launch Android applications by voice commands

 
Recent comments
2017年4月~2019年4月垃圾短信排行榜Posted at:Thu Sep 26 04:51:48 2024
Qt5.7文档翻译:QWebEngineCookieStore类,QWebEngineCookieStore ClassPosted at:Fri Aug 11 06:50:35 2023盲盒kill -9 18289 Grebe.20230517.211749.552.mp4